#include "vtor_map.h"

#ifdef __VTOR_MAP__


int8_t VtorBitMap_GetElement(VtorBitMap* map, int x, int y)
{
	if(0 <= x && x < map->width && 0 <= y && y < map->height)
	{
		if(map->data[y / 8 * map->width + x] & (0x01 << (y%8)))
		{
			return 1;
		}
	}
	return 0;
}

void VtorBitMap_SetElement(VtorBitMap* map, int x, int y, int8_t element)
{
	if(0 <= x && x < map->width && 0 <= y && y < map->height)
	{
		if(element)
		{
			map->data[y / 8 * map->width + x] |= (0x01 << (y%8));
		}
		else
		{
			map->data[y / 8 * map->width + x] &= ~(0x01 << (y%8));
		}
	}
}

void VtorBitMap_Fill(VtorBitMap* map, int8_t element)
{
	for(int16_t h = 0; h < map->height; h++)
	{
		for(int16_t w = 0; w < map->width; w++)
		{
			map->data[h * map->width + w] = element;
		}
	}
}

int8_t VtorMap_GetElement(VtorMap* map, int x, int y)
{
	if(0 <= x && x < map->width && 0 <= y && y < map->height)
	{
		return map->data[y * map->width + x];
	}
	return 0;
}

void VtorMap_SetElement(VtorMap* map, int x, int y, int8_t element)
{
	if(0 <= x && x < map->width && 0 <= y && y < map->height)
	{
		map->data[y * map->width + x] = element;
	}
}

void VtorMap_Fill(VtorMap* map, int8_t element)
{
	for(int16_t h = 0; h < map->height; h++)
	{
		for(int16_t w = 0; w < map->width; w++)
		{
			map->data[h * map->width + w] = element;
		}
	}
}

#endif // __VTOR_MAP__


